package me.boot.sys.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import me.boot.common.data.enums.ResourceType;
import me.boot.db.mybatis.handler.BaseEnumTypeHandler;
import me.boot.db.mybatis.handler.CommaToListTypeHandler;
import me.boot.db.mybatis.interceptor.foreign.ForeignKey;
import me.boot.gen.table.annotation.ColumnComment;
import me.boot.web.common.template.entity.BaseTreeEntity;

import java.util.List;

/**
 *
 */
@Getter
@Setter
@ApiModel("资源表")
@TableName(autoResultMap = true)
public class SysResource extends BaseTreeEntity<SysResource> {

    @ForeignKey(SysResource.class)
    @ColumnComment("父级id")
    @ApiModelProperty(value = "父级id")
    @TableField
    private Long parentId;

    /**
     * 资源类型
     */
    @ApiModelProperty(value = "资源类型")
    @ColumnComment("资源类型")
    @TableField(typeHandler = BaseEnumTypeHandler.class)
    private ResourceType type;

    /**
     * 前端图标
     */
    @ApiModelProperty(value = "前端图标")
    @ColumnComment("前端图标")
    @TableField
    private String icon;

    /**
     * 前端code,与前端组件对应
     */
    @ApiModelProperty(value = "前端code")
    @ColumnComment("前端code")
    @TableField
    private String frontCode;

    /**
     * 实体类型全名
     */
    @ApiModelProperty(value = "实体类型全名")
    @ColumnComment("实体类型全名")
    @TableField
    private String entityName;

    /**
     * 路径匹配规则,形如：/admin/**
     */
    @ApiModelProperty(value = "资源路径uri")
    @ColumnComment("资源路径uri")
    @TableField
    private String apiUri;

    /**
     * 先决资源id列表: 即获取本资源,必须先获取必要的资源
     */
    @ForeignKey(SysResource.class)
    @ColumnComment("先决资源id列表")
    @ApiModelProperty(value = "先决资源id列表", notes = "逗号分隔，不可循环依赖")
    @TableField(typeHandler = CommaToListTypeHandler.class)
    private List<Long> premiseIds;

}
